<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="css/mui.min.css" rel="stylesheet" />
		<script src="js/jquery-3.1.1.min.js"></script>
		<script type="text/javascript" src="layui/layui.js" ></script>
		<script type="text/javascript" src="js/publicurl.js" ></script>
		<link rel="stylesheet" href="css/icons-extra.css" />
		<style>
			.ul-box li{
				width: 30%;
			}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav top-header" style="line-height: 35px;">
			
		    <a href="javascript:history.back(-1)" style="position: absolute;">
		    	<span class="mui-icon mui-icon-arrowleft"></span>
		    	返回
		    </a>
		    <h1 class="mui-title">楼栋概览</h1>
		</header>
		<div id="buildContent" class="mui-content">
		    <ul class="mui-table-view mui-grid-view mui-grid-9 ul-box"  id="buildbox">
	            <!--<li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">
					<a href="#">
						<span class="mui-icon-extra mui-icon-extra-hotel"></span>
						<div class="mui-media-body">Home</div>
					</a>
				</li>
				<li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">
					<a href="#">
						<span class="mui-icon-extra mui-icon-extra-hotel"></span>
						<div class="mui-media-body">Home</div>
					</a>
				</li>-->
			</ul> 
		</div>
		<script src="js/mui.min.js"></script>
		<script type="text/javascript">
			mui.init({
				pullRefresh:{
					container:"#buildContent",//下拉刷新容器标识，querySelector能定位的css选择器均可，比如：id、.class等
				    down : {
				      style:'circle',//必选，下拉刷新样式，目前支持原生5+ ‘circle’ 样式
				      color:'#2BD009', //可选，默认“#2BD009” 下拉刷新控件颜色
				      height:'50px',//可选,默认50px.下拉刷新控件的高度,
				      range:'100px', //可选 默认100px,控件可下拉拖拽的范围
				      offset:'0px', //可选 默认0px,下拉刷新控件的起始位置
				      auto: true,//可选,默认false.首次加载自动上拉刷新一次
				      callback :getBuilds //必选，刷新函数，根据具体业务来编写，比如通过ajax从服务器获取新数据；
				    }
				}
			});
			var url = window.location.href;
			var urlid = url.split("?")[1];
			var id = urlid.split("=")[1];
			
			function getBuilds() {
				$("#buildbox").empty();
				layui.use(['form','layer'],function() {
				var form = layui.form;
				var layer = layui.layer;
				mui.ajax(puburl.url+"/dangxia/user/getBuildingsByAreaId", {
					data: {
						"id":id
					},
					dataType: 'json', //服务器返回json格式数据
					type: 'post', //HTTP请求类型
					timeout: 5000, //超时时间设置为10秒；
					success: function(data1) {
						if(data1.code==0) {
							mui("#buildContent").pullRefresh().endPulldown();
							$.each(data1.data, function(index,d) {
								$("#buildbox").append(
									"<li class='mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3'>"
								  +    "<a href='rooms.html?id="+d.id+"'>"
								  +	   "<span class='mui-icon-extra mui-icon-extra-hotel'></span>"
								  +	   		"<div class='mui-media-body'>"+d.building_name+"</div>"
								  +		"</a>"
								  +	"</li>"
								);
							});
							
							
						} else {
							layer.msg(data1.msg);
							mui("#buildContent").pullRefresh().endPulldown();
						}
					},
					error: function(xhr, type, errorThrown) { //异常处理；
						layer.msg("连接异常");
						mui("#buildContent").pullRefresh().endPulldown();
					}
				});
				
				});
			}
		</script>
	</body>

</html>